package com.ycode.bang.anbang.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.ycode.bang.anbang.R;
import com.ycode.bang.anbang.model.TroubleTyoe;

import java.util.List;

import butterknife.ButterKnife;
import butterknife.InjectView;

/**
 * Created by maosongsong on 2016/4/8.
 * 创建那个选择报修类型什么适配器
 */
public class CreateSelectAdapter extends ArrayAdapter<TroubleTyoe> {
    private Context mcontext;
    private LayoutInflater layoutInflater;
    public List<TroubleTyoe> list;

    public CreateSelectAdapter(Context context, List<TroubleTyoe> list) {
        super(context, 0, list);
        this.mcontext = context;
        this.list = list;
        layoutInflater = LayoutInflater.from(context);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Holder holder;
        if (null == convertView) {
            convertView = layoutInflater.inflate(R.layout.item_select_troblue, null);
            ButterKnife.inject(this, convertView);
            holder = new Holder(convertView);
            convertView.setTag(holder);
        } else {
            holder = (Holder) convertView.getTag();
        }
        holder.mTvnm.setText(list.get(position).getAlias());
//        if (list.get(position).getIsCheck()) {
//            holder.lin_people.setBackgroundColor(mcontext.getResources().getColor(R.color.lightgray4));
//        } else {
//            holder.lin_people.setBackgroundColor(mcontext.getResources().getColor(R.color.white));
//        }
        return convertView;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    class Holder {
        Holder(View view) {
            ButterKnife.inject(this, view);
        }

        @InjectView(R.id.tv_name)
        public TextView mTvnm;

        @InjectView(R.id.lin_people)
        public LinearLayout lin_people;

    }
}
